<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_saleorder_pigdetail".
 *
 * @property string $id
 * @property integer $saleorderid
 * @property string $no
 * @property integer $pigid
 * @property string $weight
 * @property string $price
 * @property integer $createtime
 * @property string $unit
 * @property string $remark
 */
class BusinessSaleorderPigdetail extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_saleorder_pigdetail';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['saleorderid', 'pigid', 'createtime'], 'integer'],
            [['weight', 'price'], 'number'],
            [['no'], 'string', 'max' => 255],
            [['unit'], 'string', 'max' => 10],
            [['remark'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'saleorderid' => '订货单id',
            'no' => '仔猪的编号',
            'pigid' => '所属猪仔',
            'weight' => '重量单位，千克',
            'price' => '售价',
            'createtime' => '创建时间',
            'unit' => '销售单位',
            'remark' => '备注',
        ];
    }


    /**
     * @return \yii\db\ActiveQuery
     * 获取对应的仔猪
     */
    public function getPig()
    {
        return $this->hasOne(BusinessPig::className(),['id'=>'pigid']);
    }
}
